My meme is using the Drake template…
```r
library(tidyverse)
library(magick)
# Script to recreate a meme using R
# Author: jmcd501
# Read and save meme images to variables
drake_unhappy <- image_read("drake_unhappy.png") %>%
image_scale(500)
drake_happy <- image_read("drake_happy.png") %>%
image_scale(500)
# Create a blank image and attach comments
top_comment <- image_blank(500, 333, color = "#000") %>%
image_annotate( text = "Comments to describe\n the program",
gravity = "center", size = 30, color = "#FFF")
bottom_comment <- image_blank(500, 281, color = "#000") %>%
image_annotate( text = "Comments to temporarily\n remove part of the code",
gravity = "center", size = 30, color = "#FFF")
# Creating the rows
top_row <- image_append(c(drake_unhappy, top_comment))
bottom_row <- image_append(c(drake_happy, bottom_comment))
# Combine the top and bottom rows, then save the image
c(top_row, bottom_row) %>%
image_append(stack = TRUE) %>%
image_scale(800) %>%
image_write("meme.png")
```
```r
library(magick)
# R program to create a GIF from scratch
# Author: jmcd501
# Read each image into frames 1-10
frame1 <- image_read("./frames/batman-1.png")
frame2 <- image_read("./frames/batman-2.png")
frame3 <- image_read("./frames/batman-3.png")
frame4 <- image_read("./frames/batman-4.png")
frame5 <- image_read("./frames/batman-5.png")
frame6 <- image_read("./frames/batman-6.png")
frame7 <- image_read("./frames/batman-7.png")
frame8 <- image_read("./frames/batman-8.png")
frame9 <- image_read("./frames/batman-9.png")
frame10 <- image_read("./frames/batman-10.png")
# combine each frame in order
frames <- c(frame1, frame2, frame3, frame4, frame5, frame6, frame7, frame8,
frame9, frame10)
# animate the frame, and annotate with the comment - then save the file.
image_animate(frames, fps=10) %>%
image_annotate(text="data structures be like", gravity = "south", size=35,
color="#FFF") %>%
image_scale(800) %>%
image_write("batman.gif")
```
/* Import my preffered font */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
/* Apply universal styles */
body {
font-family: 'Montserrat', sans-serif;
background-color: #000;
align-items:center;
color: #FFF;
}
h1, h2 {
font-weight: bold;
}
h3 {
font-style: italic;
}
h2 {
border-bottom: 5px solid #C71585;
border-radius: 50%;
color: #FFF;
text-align: center;
padding-top: 5px;
width: fit-content;
margin: auto;
padding: 5px 20px;
}
h4 {
border-bottom: 5px solid #C71585;
border-radius: 4px;
padding-bottom: 5px;
}
/* Align all items */
p {
text-align: center;
padding: 5px 5px;
}
/* To give the meme and gif the same curves as code blocks */
img {
border-radius: 4px;
}
code.hljs {
color: #FFF;
}
pre, pre:not([class]) {
background-color: #000;
}!important